<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Boost.Range sliced</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../../index.html" title="Chapter 1. Geometry">
<link rel="up" href="../boost_range.html" title="Boost.Range">
<link rel="prev" href="reversed.html" title="Boost.Range reversed">
<link rel="next" href="strided.html" title="Boost.Range strided">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="reversed.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_range.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="strided.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="geometry.reference.adapted.boost_range.sliced"></a><a class="link" href="sliced.html" title="Boost.Range sliced">Boost.Range
          sliced</a>
</h5></div></div></div>
<p>
            Boost.Range sliced range adaptor is adapted to Boost.Geometry
          </p>
<h6>
<a name="geometry.reference.adapted.boost_range.sliced.h0"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.description"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.description">Description</a>
          </h6>
<p>
            Boost.Range sliced range adaptor creates a slice of a range (usually
            a linestring)
          </p>
<h6>
<a name="geometry.reference.adapted.boost_range.sliced.h1"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.model_of"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.model_of">Model
            of</a>
          </h6>
<p>
            The Boost.Range sliced range adaptor takes over the model of the original
            geometry, which might be:
          </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                a linestring
              </li>
<li class="listitem">
                a ring
              </li>
<li class="listitem">
                a multi_point
              </li>
<li class="listitem">
                a multi_linestring
              </li>
<li class="listitem">
                a multi_polygon
              </li>
</ul></div>
<h6>
<a name="geometry.reference.adapted.boost_range.sliced.h2"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.header"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.header">Header</a>
          </h6>
<p>
            <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_range</span><span class="special">/</span><span class="identifier">sliced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
          </p>
<p>
            The standard header <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span></code>
            does not include this header.
          </p>
<h6>
<a name="geometry.reference.adapted.boost_range.sliced.h3"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_range.sliced.example"></a></span><a class="link" href="sliced.html#geometry.reference.adapted.boost_range.sliced.example">Example</a>
          </h6>
<p>
            Shows how to use a Boost.Geometry linestring, sliced by Boost.Range adaptor
          </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_range</span><span class="special">/</span><span class="identifier">sliced</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <a class="co" name="geometry.reference.adapted.boost_range.sliced.c0" href="sliced.html#geometry.reference.adapted.boost_range.sliced.c1"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>


<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">assign</span><span class="special">;</span>

    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">d2</span><span class="special">::</span><span class="identifier">point_xy</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">xy</span><span class="special">;</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">linestring</span><span class="special">&lt;</span><span class="identifier">xy</span><span class="special">&gt;</span> <span class="identifier">line</span><span class="special">;</span>
    <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">);</span>
    <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
    <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span>
    <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span>
    <span class="identifier">line</span> <span class="special">+=</span> <span class="identifier">xy</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="number">4</span><span class="special">);</span>

    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span>
        <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">line</span> <span class="special">|</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">::</span><span class="identifier">sliced</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">3</span><span class="special">))</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>

    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
          </p>
<div class="calloutlist"><table border="0" summary="Callout list"><tr>
<td width="5%" valign="top" align="left"><p><a name="geometry.reference.adapted.boost_range.sliced.c1"></a><a href="#geometry.reference.adapted.boost_range.sliced.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
<td valign="top" align="left"><p>
                At the end to avoid conflicts with Boost.QVM
              </p></td>
</tr></table></div>
<p>
            Output:
          </p>
<pre class="programlisting">((1, 1), (2, 2))
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2021 Barend Gehrels,
      Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="reversed.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_range.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="strided.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
